﻿
<div class="panel panel-default padding-empty">
    <div class="panel-body padding-empty">
        <ol class="breadcrumb margin-empty">
            <li class="breadcrumb-color"><i class="fa fa-home"></i>&nbsp;主页</li>
            <li><a href="#/examPlan/list" class="breadcrumb-link">考试计划管理</a></li>
            <li><a href="#/examRoom/list/{{planId}}/{{planName}}" class="breadcrumb-link">{{planName}} - 考场管理</a></li>
            <li class="active">{{roomName}} - 考场设置</li>
        </ol>
    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">
        <!--<h3 class="modal-title">
            <i class="fa fa-cog"></i>
            考场设置

            &nbsp;
            <button class="btn btn-turquoise btn-xs" onclick="javascript:history.go(-1);" title="返回上一页" style="margin-bottom: 0;">
                <i class="fa fa-chevron-left"></i>
            </button>
        </h3>-->

        <div class="panel-options">
            <button class="btn btn-turquoise" ng-click="addOne();" ng-hide="addComputer">
                <i class="fa fa-plus"></i>
                <span>单个添加IP和座位号</span>
            </button>

            <button class="btn btn-turquoise" ng-click="addMore();" ng-hide="addComputer">
                <i class="fa fa-plus"></i>
                <span>批量添加IP和座位号</span>
            </button>

            <button class="btn btn-turquoise" ng-click="removeComputer();">
                <i class="fa fa-close"></i>
                <span>批量删除</span>
            </button>
        </div>
    </div>

    <div class="panel-body">
        <!--单个添加IP和座位号-->
        <div ng-show="visible">
            <form id="addOneForm" role="form" class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-4 control-label">考试机 IP：</label>

                    <div class="col-sm-8">
                        <input type="text" class="form-control width-fiexd-150 input-inline" name="computerIP" ng-model="computerIP" ng-disabled="loadingState" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">座位号：</label>

                    <div class="col-sm-8">
                        <input type="text" class="form-control width-fiexd-150 input-inline" name="seatNo" ng-model="seatNo" ng-disabled="loadingState" />
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <button type="submit" class="btn btn-turquoise" ng-click="saveOne();" ng-disabled="loadingState">
                            <i class="fa fa-spinner fa-spin" ng-show="loadingState"></i>
                            <i class="fa fa-save" ng-hide="loadingState"></i>
                            <span>保存</span>
                        </button>
                        <button type="button" class="btn btn-gray" ng-click="cancelOne();" ng-disabled="loadingState">
                            <i class="fa fa-close"></i>
                            <span>取消</span>
                        </button>
                    </div>
                </div>
            </form>

            <hr />
        </div>

        <!--批量添加IP和座位号-->
        <div ng-show="visibles">
            <form id="addMoreForm" role="form" class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-4 control-label">添加考试机IP：</label>

                    <div class="col-sm-8">
                        <input type="text" class="form-control width-fiexd-150 input-inline" id="computerStartIP" name="computerStartIP" ng-model="computerStartIP" ng-disabled="loadingState" />
                        -
                        &nbsp;
                        <input type="text" class="form-control width-fiexd-150 input-inline" id="computerEndIP" name="computerEndIP" ng-model="computerEndIP" ng-disabled="loadingState" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">起始座位号：</label>

                    <div class="col-sm-8">
                        <input type="text" class="form-control width-fiexd-150 input-inline" id="seatNO" name="seatNO" ng-model="seatNO" ng-disabled="loadingState" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <label class="control-label">
                            <input type="radio" name="order" value="0" ng-model="order" ng-init="order=0" ng-disabled="loadingState" />
                            按IP升序
                        </label>
                        <label class="control-label">
                            <input type="radio" name="order" value="1" ng-model="order" ng-disabled="loadingState" />
                            按IP降序
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <button type="submit" class="btn btn-turquoise" ng-click="saveMore();" ng-disabled="loadingState">
                            <i class="fa fa-spinner fa-spin" ng-show="loadingState"></i>
                            <i class="fa fa-save" ng-hide="loadingState"></i>
                            <span>保存</span>
                        </button>
                        <button type="button" class="btn btn-gray" ng-click="cancelMore();" ng-disabled="loadingState">
                            <i class="fa fa-close"></i>
                            <span>取消</span>
                        </button>
                    </div>
                </div>
            </form>

            <hr />
        </div>

        <table class="table responsive table-bordered table-hover">
            <tr class="active">
                <th class="text-center" width="10">
                    <input type="checkbox" title="全选" ng-click="checkAll()" ng-checked="isCheckAll" />
                </th>
                <th class="text-center">#</th>
                <th>考试机IP</th>
                <th>座位号</th>
                <th>考试机状态</th>
                <th>更新时间</th>
                <!--<th>操作</th>-->
            </tr>
            <tr ng-repeat="item in list | orderBy:'seatNo'" ng-click="clickLine(item)" style="cursor:pointer;">
                <!--复选框-->
                <th class="text-center">
                    <input type="checkbox" ng-checked="item.isChecked" value="{{item.examComputerID}}" />
                </th>
                <!--序号-->
                <th class="text-center" ng-bind="$index+1"></th>
                <!--考试机IP-->
                <td>
                    <span ng-bind="item.computerIP" ng-hide="item.modifyIp" ng-click="modify(item,0)"></span>
                    <input type="text" ng-model="item.ComputerIP" ng-show="item.modifyIp" ng-blur="saveModify(item,0)" />
                </td>
                <!--座位号-->
                <td>
                    <span ng-bind="item.seatNo" ng-hide="item.modifySeatIp" ng-click="modifySeat(item,0)"></span>
                    <input type="text" ng-model="item.SeatNo" ng-show="item.modifySeatIp" ng-blur="saveModifySeat(item,0)" />
                </td>
                <!--考试机状态-->
                <td>
                    暂定
                </td>
                <!--更新时间-->
                <td ng-bind="item.updateTime | formatDateNoSs | date: 'yyyy-MM-dd HH:mm'"></td>
                <!--<td>
                    <button class="btn btn-turquoise" ng-click="modify(item,0)">
                        修改IP
                    </button>
                    <button class="btn btn-turquoise" ng-click="modify(item,1)">
                        修改座位号
                    </button>
                </td>-->
            </tr>
        </table>

        <h3 class="text-center" ng-show="list.length<=0">
            <small>暂无相关数据</small>
        </h3>
    </div>
</div>

<script>
    $(function () {
        $('form#addOneForm').validate({
            rules: {
                ComputerIP: {
                    required: true,
                    isIP: true
                },
                SeatNo: {
                    required: true,
                    digits: true
                }
            },
            messages: {
                ComputerIP: {
                    required: '请输入IP'
                },
                SeatNo: {
                    required: '请输入座位号',
                    digits: '请输入整数座位号'
                }
            }
        });

        $('form#addMoreForm').validate({
            rules: {
                computerStartIP: {
                    required: true,
                    isIP: true
                },
                computerEndIP: {
                    required: true,
                    isIP: true
                },
                seatNO: {
                    required: true,
                    digits: true
                }
            },
            messages: {
                computerStartIP: {
                    required: '请输入起始IP号'
                },
                computerEndIP: {
                    required: '请输入结束IP号'
                },
                seatNO: {
                    required: '请输入座位号',
                    digits: '请输入整数座位号'
                }
            }
        });
    });
</script>
